package com.yipei.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.enums.BusinessType;
import com.yipei.business.domain.MlAssetAccount;
import com.yipei.business.service.IMlAssetAccountService;
import com.yipei.common.utils.poi.ExcelUtil;
import com.yipei.common.core.page.TableDataInfo;

/**
 * 资金账号Controller
 * 
 * @author yipei
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/business/assetaccount")
@Api(tags = "资金账号", description = "资金账号管理")
public class MlAssetAccountController extends BaseController
{
    @Autowired
    private IMlAssetAccountService mlAssetAccountService;

    /**
     * 查询资金账号列表
     */
    //@PreAuthorize("@ss.hasPermi('business:assetaccount:list')")
    @GetMapping("/list")
    @ApiOperation("资金账号获取数据")
    public TableDataInfo list(MlAssetAccount mlAssetAccount)
    {
        startPage();
        List<MlAssetAccount> list = mlAssetAccountService.selectMlAssetAccountList(mlAssetAccount);
        return getDataTable(list);
    }

    /**
     * 导出资金账号列表
     */
    @ApiOperation("资金账号数据导出")
    //@PreAuthorize("@ss.hasPermi('business:assetaccount:export')")
    @Log(title = "资金账号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlAssetAccount mlAssetAccount)
    {
        List<MlAssetAccount> list = mlAssetAccountService.selectMlAssetAccountList(mlAssetAccount);
        ExcelUtil<MlAssetAccount> util = new ExcelUtil<MlAssetAccount>(MlAssetAccount.class);
        util.exportExcel(response, list, "资金账号数据");
    }

    /**
     * 获取资金账号详细信息
     */
    @ApiOperation("资金账号通过ID获取数据")
    //@PreAuthorize("@ss.hasPermi('business:assetaccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mlAssetAccountService.selectMlAssetAccountById(id));
    }

    /**
     * 新增资金账号
     */
    @ApiOperation("资金账号新增数据")
    //@PreAuthorize("@ss.hasPermi('business:assetaccount:add')")
    @Log(title = "资金账号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlAssetAccount mlAssetAccount)
    {
        return toAjax(mlAssetAccountService.insertMlAssetAccount(mlAssetAccount));
    }

    /**
     * 修改资金账号
     */
    @ApiOperation("资金账号修改数据")
    //@PreAuthorize("@ss.hasPermi('business:assetaccount:edit')")
    @Log(title = "资金账号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlAssetAccount mlAssetAccount)
    {
        return toAjax(mlAssetAccountService.updateMlAssetAccount(mlAssetAccount));
    }

    /**
     * 删除资金账号
     */
    @ApiOperation("资金账号删除数据")
    //@PreAuthorize("@ss.hasPermi('business:assetaccount:remove')")
    @Log(title = "资金账号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mlAssetAccountService.deleteMlAssetAccountByIds(ids));
    }
}
